package com.ruoyi.web.controller.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.ShopPointsIncome;
import com.ruoyi.shop.service.IShopPointsIncomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 积分获取记录Controller
 * 
 * @author liuwp
 * @date 2025-11-24
 */
@RestController
@RequestMapping("/shop/shop_points_income")
public class ShopPointsIncomeController extends BaseController
{
    @Autowired
    private IShopPointsIncomeService shopPointsIncomeService;

    /**
     * 查询积分获取记录列表
     */
    @PreAuthorize("@ss.hasPermi('shop:shop_points_income:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopPointsIncome shopPointsIncome)
    {
        startPage();
        List<ShopPointsIncome> list = shopPointsIncomeService.selectShopPointsIncomeList(shopPointsIncome);
        return getDataTable(list);
    }

    /**
     * 导出积分获取记录列表
     */
    @PreAuthorize("@ss.hasPermi('shop:shop_points_income:export')")
    @Log(title = "积分获取记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopPointsIncome shopPointsIncome)
    {
        List<ShopPointsIncome> list = shopPointsIncomeService.selectShopPointsIncomeList(shopPointsIncome);
        ExcelUtil<ShopPointsIncome> util = new ExcelUtil<ShopPointsIncome>(ShopPointsIncome.class);
        util.exportExcel(response, list, "积分获取记录数据");
    }

    /**
     * 获取积分获取记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:shop_points_income:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shopPointsIncomeService.selectShopPointsIncomeById(id));
    }

    /**
     * 新增积分获取记录
     */
    @PreAuthorize("@ss.hasPermi('shop:shop_points_income:add')")
    @Log(title = "积分获取记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopPointsIncome shopPointsIncome)
    {
        return toAjax(shopPointsIncomeService.insertShopPointsIncome(shopPointsIncome));
    }

    /**
     * 修改积分获取记录
     */
    @PreAuthorize("@ss.hasPermi('shop:shop_points_income:edit')")
    @Log(title = "积分获取记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopPointsIncome shopPointsIncome)
    {
        return toAjax(shopPointsIncomeService.updateShopPointsIncome(shopPointsIncome));
    }

    /**
     * 删除积分获取记录
     */
    @PreAuthorize("@ss.hasPermi('shop:shop_points_income:remove')")
    @Log(title = "积分获取记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopPointsIncomeService.deleteShopPointsIncomeByIds(ids));
    }


    @GetMapping("/query")
    public TableDataInfo query(ShopPointsIncome shopPointsIncome)
    {
        shopPointsIncome.setUserId(SecurityUtils.getUserId());
        startPage();
        List<ShopPointsIncome> list = shopPointsIncomeService.selectShopPointsIncomeList(shopPointsIncome);
        return getDataTable(list);
    }
}
